package com.dfrz.ch02;/*
 * @创建者：黄苟苟
 * @创建时间：2021/6/7   20:20
 * @Description描述
 **/

import java.util.Scanner;

public class TestTriangle {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("输入三角形的边a:");
        int a = scanner.nextInt();
        System.out.println("输入三角形的b:");
        int b = scanner.nextInt();
        System.out.println("输入三角形的边c:");
        int c = scanner.nextInt();
        if ( a!=0&&b!=0&&c!=0){


            if ( a + b > c && a + c > b && b + c > a){
                int total = a + b + c;
                double p = total/2;
                double s = Math.sqrt(p * (p - a) * (p - b) * (p - c));
                System.out.println("三角形面积为：" + s);
                System.out.println("三角形周长为：" + total);
            }else {
                System.out.println("这不是三角形");
            }
        }else{
            System.out.println("三角形边长不能为0");
        }

    }
}
